import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CardDemo {
    public static final String[] SULT =  {"♠", "♥", "♣", "♦"};
    public static List<Card> buyCard(){
        List<Card> cardList = new ArrayList<>();
        for (int i = 0; i < SULT.length; i++) {
            for (int j = 1; j <= 13; j++) {
                Card card = new Card(j,SULT[i]);
                cardList.add(card);
            }
        }
        return cardList;
    }
    public static void shuffe(List<Card> cardList){
        for (int i = cardList.size(); i > 0; i++) {
            Random random = new Random();
            int index = random.nextInt(i);
            swap(cardList,i,index);
        }
    }
    private static void swap(List<Card> cardlist ,int x,int y){
        Card tmp = cardlist.get(x);
        cardlist.set(x,cardlist.get(y));
        cardlist.set(y,tmp);
    }

    public static void main(String[] args) {
        List<Card> cardlist = buyCard();
        System.out.println(cardlist);
        shuffe(cardlist);
        System.out.println("揭牌：");
        List<Card> hand0 = new ArrayList<>();
        List<Card> hand1 = new ArrayList<>();
        List<Card> hand2 = new ArrayList<>();
        List<List<Card>> hands = new ArrayList<>();
        hands.add(hand0);
        hands.add(hand1);
        hands.add(hand2);
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Card card = cardlist.remove(0);
                hands.get(j).add(card);
            }
        }
    }
}
